<%@include file="/include/head.jspf" %>	
<%@page import="java.util.*, com.atech.ace.entity.*" %>
<jsp:useBean id="catalog" scope="request" class="java.util.LinkedHashMap" />
<script type="text/javascript">
function addProduct(pid)
{
  var qty = document.catalog.elements[pid+'_quantity'].value;
  var URL = "/ACEShopWeb/cart?pid="+pid+"&qty="+qty;
  var result;
  dojo.xhrPost(
   {
    url: URL,
    handleAs: "text", 
    load: result
   }); 
}
</script>	
	<div align="center">
	<form name="catalog" action="/ACEShopWeb/store/checkout.jsp">
<table bgcolor="white" border="1" width="95%" cellpadding="5" cellspacing="5">
<%
  Iterator i = catalog.entrySet().iterator();
  while(i.hasNext())
  {
     Map.Entry me = ( Map.Entry ) i.next();
     Category c = ( Category ) me.getKey();
     List products = ( List ) me.getValue();
     Iterator pi = products.iterator();     
 %>
 <tr><td colspan="2" bgcolor="blue"><font color="white"><b><%=c.getDescription()%></b></font></td></tr>
 <tr>
 <%
   	  int counter = 0;
      while(pi.hasNext())
      {
        Product product = ( Product ) pi.next();
  %>
  <td><img src="/ACEShopWeb/<%=product.getImageUrl()%>" width="168" height="168"/>&nbsp;<%=product.getName()%><br />
  <%=product.getDescription()%>
  <br />
  $<%=product.getPrice()%>
  <br />
  Quantity:<input type="text size="2" name="<%=product.getProductId()%>_quantity"/>&nbsp;<input type="button" value="Add to Cart" onClick="javascript:addProduct('<%=product.getProductId()%>');" />
  </td>
  <%
     	if(counter % 2 == 0)
     	{
   %>
   </tr><tr>
   <%	}    
   	  }
   	 }
   %>
   
</table>	
</form>
</div>
<%@include file="/include/footer.jspf" %>